package com.flame.workflow.re.service;

import java.util.List;

import com.flame.workflow.re.controller.vo.DeploymentVo;
import com.flame.workflow.re.entity.Deployment;
import com.flame.workflow.re.entity.Model;
import com.flame.workflow.re.mapper.DeploymentMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * flame_workflow_re_deployment 流程部署信息表
 *
 * @author 吴欣童
 * @since 2023-05-07 11:23:03
 */
@Service
public class DeploymentService {

    @Autowired
    private DeploymentMapper deploymentMapper;

    public List<Model> listDeployment(DeploymentVo deploymentVo) {
        return deploymentMapper.list(deploymentVo);
    }

    public void maintainDeployment(Deployment deployment) {
        Deployment dbDeployment = deploymentMapper.findById(deployment.getModelId());
        if (dbDeployment != null) {
            deploymentMapper.updateById(deployment);
        } else {
            deploymentMapper.insert(deployment);
        }
    }

    public void deleteDeployment(Deployment deployment) {
        deploymentMapper.deleteById(deployment.getModelId());
    }
}
